home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from unicodedata import category, decomposition
- NAME_START_CATEGORIES = [
- 'Ll',
- 'Lu',
- 'Lo',
- 'Lt',
- 'Nl']
- NAME_CATEGORIES = NAME_START_CATEGORIES + [
- 'Mc',
- 'Me',
- 'Mn',
- 'Lm',
- 'Nd']
- ALLOWED_NAME_CHARS = [
- u'·',
- u'·',
- u'-',
- u'.',
- u'_']
-
- def is_ncname(name):
- first = name[0]
- if first == '_' or category(first) in NAME_START_CATEGORIES:
- for i in xrange(1, len(name)):
- c = name[i]
- if category(c) not in NAME_CATEGORIES:
- if c in ALLOWED_NAME_CHARS:
- continue
-
- return 0
-
- return 1
- return 0
-
- XMLNS = 'http://www.w3.org/XML/1998/namespace'
-
- def split_uri(uri):
- if uri.startswith(XMLNS):
- return (XMLNS, uri.split(XMLNS)[1])
- length = len(uri)
- for i in xrange(0, length):
- c = uri[-i - 1]
- if category(c) not in NAME_CATEGORIES:
- if c in ALLOWED_NAME_CHARS:
- continue
-
- for j in xrange(-1 - i, length):
- if category(uri[j]) in NAME_START_CATEGORIES or uri[j] == '_':
- ns = uri[:j]
- if not ns:
- break
-
- ln = uri[j:]
- return (ns, ln)
-
- break
- continue
- uri[j] == '_'
-
- raise Exception("Can't split '%s'" % uri)
-
-